package classes;

import interfaces.Atacante;
import interfaces.Defensor;
import interfaces.Posicionable;

public abstract class Persona extends Posicionable implements Defensor, Atacante {

	private Posicion position;
	private int PATK;
	private int rangoAtk = 1;
	
	public Persona() {
		this.setEnergia(100);
		this.setSize(new Rect(1,1));
	}

	public void atacarA(Defensor d) {
		// Si el objetivo esta dentro del rango, atacarlo
		if(Posicion.distancia(d.getPosition(), this.getPosition()) <= this.getRangoAtk()){
			d.teAtaca(this);
		}
	}
	
	public void setRangoAtk(int rangoAtk) {
		this.rangoAtk = rangoAtk;
	}

	public boolean ocupa(Posicion p) {
		return this.getSize().ocupa(p);
	}

	public void teAtaca(Atacante a) {
		this.setEnergia(this.getEnergia() - a.getPATK());
	}
	
	public int getRangoAtk() {
		return rangoAtk;
	}

	public Posicion getPosition() {
		return position;
	}
	public void setPosition(Posicion position) {
		this.position = position;
	}
	public int getPATK() {
		return PATK;
	}
	public void setPATK(int pATK) {
		PATK = pATK;
	}
	
}
